Ext.define('Admin.view.employee.PhotoForm', {
    extend: 'Ext.form.Panel',
    xtype:'photoForm',
    id:'photoForm',
    requires: [
        'Ext.button.Button'
    ],
    
    controller: 'employeeViewController',

  // title: 'ExtJS 无刷新文件上传（<font color="red">文件最大</font>)',
    width: '95%',
    height: '95%',
    x:5,
    y: 5,
    layout: "form",
    bodyPadding: "5",
    defaultType: "textfield",
    fieldDefaults: { labelAlign: "left", labelWidth: 55 },
    items: [ {
        xtype: 'filefield',
        name: 'photo',
        fieldLabel: '选择照片',
        labelWidth: 50,
        msgTarget: 'side',
        allowBlank: false,
        anchor: '100%',
        buttonText: '浏览文件'
        }],


    buttons:[{
        text:'上传', 
        handler:function(btn) {
            var upform=btn.up('form');
        // console.log(upform);
            upform.getForm().submit({
             url:'employee/saveIdcardImg',
             method:'post',
             params:{ 
                empId :10
             }, 
             success:function(form, action, o) {  
                     Ext.MessageBox.alert("提示信息",action.result.msg);
                     var win = btn.up('window');
                     if (win) {
                         win.close();
                     };
                                    Ext.getCmp('employeeImformationForm').load({
                                    url:'employee/test?id=10',
                                    success: function(form, action) {
                                    Ext.getCmp("myPhoto").getEl().dom.src=""+action.result.data.idcardImg+"";

                                    } 
                                    });
            },  
            failure : function(form, action) {  
                Ext.MessageBox.alert("提示信息","请求失败,文件上传失败");  
            }  
           });
        }
   }] 
});